// ~ Package Declaration
// ==================================================

package com.wms.data.dao;

import com.wms.data.pojo.Pojo;

import java.io.Serializable;
import java.util.List;

// ~ Comments
// ==================================================

/**
 * 
 * all dao parent.
 * 
 * <pre>
 * 歷史紀錄：
 * 2008/11/5 Timothy
 * 	新建檔案
 * </pre>
 * 
 * @author <pre>
 * SD
 * 	Timothy
 * PG
 * 
 * UT
 * 
 * MA
 * </pre>
 * @version $Rev$
 * 
 *          <p/>
 *          $Id$
 * 
 */
public interface Dao<P extends Pojo<PK>, PK extends Serializable> {

	// ~ Static Fields
	// ==================================================

	// ~ Methods
	// ==================================================

	/**
	 * <pre>
	 * 2008/11/5 Timothy
	 * 	回傳 dao 操作的 pojo 類別
	 * </pre>
	 * 
	 * @return
	 */
	Class<P> getPojoClass();

	/**
	 * <pre>
	 * 2008/11/5 Timothy
	 * 	Find pojo by id, if didn't query the pojo, return null;
	 * </pre>
	 * 
	 * @param id
	 *          primary key
	 * @return if didn't query the pojo, return null; else return pojo.
	 */
	P findById(PK id);

	/**
	 * <pre>
	 * 2008/11/5 Timothy
	 * 	Find all pojos
	 * </pre>
	 * 
	 * @return
	 */
	List<P> findAll();
	
	/**
	 * find all by district id.
	 *
	 * <pre>
	 * 	find all by district id.
	 * </pre>
	 *
	 * @param districtRid
	 * @return List<P>
	 */
	List<P> findAllByDistrictRid(Long districtRid);

	/**
	 * <pre>
	 * 2008/11/5 Timothy
	 * 	Create a pojo.
	 * </pre>
	 * 
	 * @param pojo
	 */
	void create(P pojo);
	
	PK save(P pojo);
	
	Long createReturnId(P pojo);

	/**
	 * <pre>
	 * 2008/11/5 Timothy
	 * 	Update a pojo by id.
	 * </pre>
	 * 
	 * @param pojo
	 */
	void update(P pojo);

	/**
	 * 
	 * <pre>
	 * 2008/11/5 Timothy
	 * 	Delete a pojo by id.
	 * </pre>
	 * 
	 * @param pojo
	 */
	void delete(P pojo);

	/**
	 * 
	 * <pre>
	 * 2008/11/5 Timothy
	 * 	Delete a pojo by id.
	 * </pre>
	 * 
	 * @param pojo
	 */
	void delete(PK id);

	/**
	 * <pre>
	 * 2010-2-3 Timothy
	 * Check exists pojo by id
	 * </pre>
	 * 
	 * @param id
	 * @return true : if pojo exist!
	 */
	boolean exists(PK id);

	/**
	 * <pre>
	 * 2010-2-3 Timothy
	 * Check not exists pojo by id
	 * </pre>
	 * 
	 * @param id
	 * @return true : if pojo not exist!
	 */
	boolean notExists(PK id);
	
	/**
	 * createDetails.
	 *
	 * <pre>
	 * 	createDetails
	 * </pre>
	 *
	 * @param before
	 * @param after
	 * @param columns
	 */
	String createDetails(Object before, Object after,String[] columns,String tableName);
	
	/**
	 * getColumns.
	 *
	 * <pre>
	 * 	2012/4/19
	 * </pre>
	 *
	 * @return
	 */
	String[] getColumns();
}
